package cn.tutu.blockchain.transrecord.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import cn.tutu.blockchain.common.Page;
import cn.tutu.blockchain.transrecord.dao.TransRecordDao;
import cn.tutu.blockchain.transrecord.entity.TransRecord;
import cn.tutu.blockchain.transrecord.service.TransRecordService;

@Service
@Transactional
public class TransRecordServiceImpl implements TransRecordService {

	@Autowired
	private TransRecordDao transRecordDao;

	@Override
	public PageInfo<TransRecord> getByUserId(String userId, Page page) {
		PageHelper.startPage(page.getPageNum(), page.getPageSize());
		List<TransRecord> list = transRecordDao.findByUserId(userId);
		PageInfo<TransRecord> pageInfo = new PageInfo<TransRecord>(list);
		return pageInfo;
	}

	@Override
	public void create(TransRecord transRecord) {
		transRecordDao.insert(transRecord);
	}

}
